package servlet4;

import com.google.gson.Gson;
import dao.DB;
import entity.UserLogin;
import service.UserService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;


//好友信息
@WebServlet("/friendinfo")
public class friendinfoServlet extends HttpServlet {

    private UserService UserSer = new UserService();

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        req.setCharacterEncoding("UTF-8");
        resp.setCharacterEncoding("UTF-8");



//        Cookie[] cookies = req.getCookies();
//
//        String newToken = null;
//        for (Cookie cookie : cookies) {
//            if (cookie.getName().equals("TOKEN")) {
//                newToken = cookie.getValue();
//            }
//        }



        String fid = req.getParameter("fid");

        List friid = DB.executeQuery("SELECT friendid FROM friend  WHERE userid= ? and friStatus =1",fid);
       List list = DB.executeQuery("SELECT * FROM friend f LEFT JOIN `user` u on f.friendid = u.account WHERE u.account = ? and f.friStatus =1",fid);




        resp.getWriter().print(new Gson().toJson(list));
    }
}
